bugfix: Fix resource leaks in the WebSocket engine #253
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for the great work on this project.
What is the motivation?
Recently, CI has been failing due to WebSocket resource leaks.
Surreal's
close
method waits until the engine it is using transitions to a "disconnected" status. However, the WebSocket engine'sdisconnect
method immediately transitions to the "disconnected" status after requesting that the socket be disconnected. Theclose
method of socket (not Surreal) only requests that the connection be closed, and certainly does not wait for the connection to close. Therefore, if the socket "close" event occurs beforesetStatus
is resolved, there will be no resource leak, but ifsetStatus
is resolved first, a resource leak will occur.What does this change do?
In order to detect a WebSocket disconnection, prevent the WebSocket engine from immediately transitioning to the "disconnected" status.
What is your testing strategy?
I have verified that all existing tests pass.
Is this related to any issues?
N/A
Have you read the Contributing Guidelines?